package cn.tedu.health.service.impl;

import cn.tedu.health.mapper.RiskPredictionsMapper;
import cn.tedu.health.pojo.entity.RiskPredictions;
import cn.tedu.health.service.IRiskPredictionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;

@Service
public class RiskPredictionsService implements IRiskPredictionsService {

    @Autowired
    private RiskPredictionsMapper riskPredictionsMapper;

    @Override
    public void createRiskPrediction(RiskPredictions riskPredictions) {
        riskPredictionsMapper.insert(riskPredictions);
    }

    @Override
    public RiskPredictions getRiskPrediction(Long userId, LocalDate date) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        params.put("date", date);
        return riskPredictionsMapper.findByUserIdAndDate(params);
    }
}
